package com.imeth.cms.dao;

import com.imeth.base.MyBatisDao;
import com.imeth.base.model.Paging;
import com.imeth.cms.Media;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by peter on 12/24/2015.
 */
@MyBatisDao
public interface MediaDao {

    @Options(useGeneratedKeys=true, keyProperty="id")
    @Insert("insert into t_media(name,url) values(#{name},#{url})")
    int save(Media media);

    @Update("update t_media set name=#{name},url=#{url} where id=#{id}")
    int update(Media media);

    @Delete("delete from t_media where id = #{id}")
    int deleteById(Integer id);

    @Select("select * from t_media where id=#{id}")
    Media getById(Integer id);

    @Select("select count(1) from t_media")
    int count();

    @Select("select * from t_media limit #{startRow},#{pageSize}")
    List<Media> query(Paging paging);
}
